const { HotCommentsProxy } = require('../proxys')
module.exports = class HotCommentsController {
  static async getList (ctx) {
    const { limit = 20, offset = 0 } = ctx.query
    const cookie = ctx.get('Cookie') ? ctx.get('Cookie') : ''
    const id = ctx.params.id
    let comments = await HotCommentsProxy.getComment(limit, offset, id, cookie)
    const { hotComments = [], total = 0 } = JSON.parse(comments)
    ctx.status = 200
    ctx.response.type = 'json'
    ctx.response.body = {
      code: 0,
      data: hotComments,
      total: total
    }
  }
}
